package com.neusoft.his.sb.entity;

public class CommonResult<T> {
//	meta
	private int code = 200;
	private String msg = "OK";
//	被携带给客户端数据
	T data;
	public CommonResult( ) {
		 
	}

	public CommonResult(T data) {
		this.data = data;
	}
	
	public CommonResult(int code, String msg, T data) {
		this.code = code;
		this.msg = msg;
		this.data = data;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
		switch (this.code) {
		case  200:
			this.msg = "操作成功";
			break;
		case  201:
			this.msg = "查询成功";
			break;
		case  202:
			this.msg = "创建成功";
			break;
		case  203:
			this.msg = "修改成功";
			break;
		case  404:
			this.msg = "请求的资源不存在";
			break;
		case 250:
			this.msg="执行删改操作成功，但是影响记录行数为零";
			break;
		default:
			break;
		}
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	@Override
	public String toString() {
		return "CommonResult [code=" + code + ", msg=" + msg + ", data=" + data + "]";
	}
	
	

}
